<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>
    <script th:inline="javascript">
        $(function () {
            $.getJSON('/CarType',function (result) {
                let type=[[getId.carType]]
                $("[name=carType]").append("<option value=''>请选择</option>");
                for(let cartype of result){
                    if(cartype.tid==type){
                        $("[name=carType]").append("<option selected value='"+cartype.tid+"'>"+cartype.name+"</option>");
                    }else {
                        $("[name=carType]").append("<option  value='"+cartype.tid+"'>"+cartype.name+"</option>");
                    }
                }
            })
        })
    </script>
</head>
<body>
<form th:action="@{/cars/add}" method="post">
    <h3>添加</h3>
    <table>
        <tr>
            <td>carName</td>
            <td><input name="carName"></td>
        </tr>
        <tr>
            <td>carPrice</td>
            <td><input name="carPrice"></td>
        </tr>
        <tr>
            <td>carMileage</td>
            <td><input  name="carMileage"></td>
        </tr>
        <tr>
            <td>carBuyTime</td>
            <td><input type="date" name="carBuyTime"></td>
        </tr>
        <tr>
            <td>carType</td>
            <td>
                <select name="carType"></select>
            </td>
        </tr>
        <tr>
            <td>carStatus</td>
            <td><input name="carStatus"></td>
        </tr>
        <tr>
            <td>
                <input type="submit" value="添加">
            </td>
        </tr>
    </table>
</form>
</body>
</html>